package com.weixin.engine.design.single.hungry;

import java.io.IOException;
import java.util.Properties;

/**
 * 恶汉模式-静态代码块
 * 这种用于可以在静态代码块进行一些初始化
 */
public class HungryStaticBlockSingleton {

    private String info;

    private HungryStaticBlockSingleton(String info) {
        this.info = info;
    }

    //构造器私有化
    private HungryStaticBlockSingleton() {
    }

    //静态变量保存实例变量
    public static final HungryStaticBlockSingleton INSTANCE;

    static {
        Properties properties = new Properties();
        try {
            properties.load(HungryStaticBlockSingleton.class.getClassLoader().getResourceAsStream("info.properties"));
        } catch (IOException e) {
            e.printStackTrace();
        }
        INSTANCE = new HungryStaticBlockSingleton(properties.getProperty("info"));
    }

    public String getInfo() {
        return info;
    }

    public void setInfo(String info) {
        this.info = info;
    }
}